package com.example.ogtest.test.tool;

import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;

public class BufferTool {
	  public static Buffer bufferUtil(int []arr){  
	         IntBuffer mBuffer ;          
	         //先初始化buffer,数组的长度*4,因为一个int占4个字节  
	         ByteBuffer qbb = ByteBuffer.allocateDirect(arr.length * 4);  
	         //数组排列用nativeOrder  
	         qbb.order(ByteOrder.nativeOrder());  
	          
	         mBuffer = qbb.asIntBuffer();  
	         mBuffer.put(arr);  
	         mBuffer.position(0);  
	           
	         return mBuffer;  
	    }
}
